﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibMinecraft.Server;
using LibMinecraft.Model;

namespace PartyCraftServer.Commands
{
    public class SendCommand : Command
    {
        public override bool RequiresOp
        {
            get { return true; }
        }

        public override string DefaultCommand
        {
            get { return "send"; }
        }

        public override string Documentation
        {
            get { return "Sends a single player between dimensions.\nUsage: /send [player] [overworld|nether|end]"; }
        }

        public override void ExecuteCommand(RemoteClient client, params string[] parameters)
        {
            if (parameters.Length != 2)
            {
                client.SendChat(ChatColor.Red + "Invalid parameters.  Use /send [player] [overworld|nether|end]");
                return;
            }
            if (parameters[1].ToLower() != "overworld" &&
                parameters[1].ToLower() != "nether" &&
                parameters[1].ToLower() != "end")
            {
                client.SendChat(ChatColor.Red + "Invalid parameters.  Use /send [player] [overworld|nether|end]");
                return;
            }
            Dimension d = Dimension.Overworld;
            switch (parameters[1].ToLower())
            {
                case "nether":
                    d = Dimension.Nether;
                    break;
                case "end":
                    d = Dimension.TheEnd;
                    break;
            }
            RemoteClient target = PartyCraft.Server.GetClient(parameters[0]);
            if (target == null)
            {
                client.SendChat(ChatColor.Red + "That player is not logged onto this server.");
                return;
            }
            target.PlayerEntity.Dimension = d;
        }
    }
}
